package com.ruoyi.swla2.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.swla2.domain.MeterHistoryData;
import com.ruoyi.swla2.service.IMeterHistoryDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 远传小-历史数据Controller
 * 
 * @author gdqt
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/swla2/data")
public class MeterHistoryDataController extends BaseController
{
    @Autowired
    private IMeterHistoryDataService meterHistoryDataService;

    /**
     * 查询远传小-历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(MeterHistoryData meterHistoryData)
    {
        startPage();
        List<MeterHistoryData> list = meterHistoryDataService.selectMeterHistoryDataList(meterHistoryData);
        return getDataTable(list);
    }

    /**
     * 导出远传小-历史数据列表
     */
    @PreAuthorize("@ss.hasPermi('swla2:data:export')")
    @Log(title = "远传小-历史数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeterHistoryData meterHistoryData)
    {
        List<MeterHistoryData> list = meterHistoryDataService.selectMeterHistoryDataList(meterHistoryData);
        ExcelUtil<MeterHistoryData> util = new ExcelUtil<MeterHistoryData>(MeterHistoryData.class);
        util.exportExcel(response, list, "远传小-历史数据数据");
    }


    /**
     * 新增远传小-历史数据
     */
    @PreAuthorize("@ss.hasPermi('swla2:data:add')")
    @Log(title = "远传小-历史数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeterHistoryData meterHistoryData)
    {
        return toAjax(meterHistoryDataService.insertMeterHistoryData(meterHistoryData));
    }

}
